Node effect renderer class. More...
#include <kanzi/core.ui/node/node_effect_renderer2d.hpp>
Classes | |
struct | EffectPass |
Effect pass configuration. More... | |
struct | EffectRenderState |
Render state configuration to use with an effect pass. More... | |
Public Member Functions | |
void | applyEffect (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, const Matrix3x3 &worldTransform, const CompositionContentRequirements &requirements, TextureSharedPtr sourceContent) |
Applies the effect on the source content provided as texture. | |
void | beginEffect (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, const Matrix3x3 &worldTransform, const CompositionContentRequirements &requirements) |
Begins the effect. | |
void | blitEffect (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, const QuadDescription &effectQuad, const Matrix3x3 &transform, const Matrix4x4 *perspectiveMatrix, const Matrix4x4 *projectionMatrix, int blendMode, bool needsClear) |
Blits the effect to the current framebuffer. | |
void | endEffect (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager) |
Ends the effect. | |
NodeEffect2DSharedPtr | getEffect () const |
Get NodeEffect2D instance where this renderer has been instantiated from. | |
size_t | getEffectPassCount () const |
Gets the number of effect passes. | |
bool | isLayeredOnTop () const |
Whether a compatible effect renders logically on top of its source content. | |
bool | isRenderEffectOnlyEnabled () const |
Whether the effect only mode is enabled. | |
void | restoreResources () |
Restores resources after the rendering context has been lost. | |
void | setRenderEffectOnly (bool renderEffectOnly) |
Sets the render effect only mode. | |
virtual bool | supportsBlitBlendMode (int blendMode) |
Whether the effect is compatible with a given blend mode. | |
virtual | ~NodeEffectRenderer2D () |
Declare NodeEffectRenderer2D as not movable nor copyable. | |
Protected Types | |
using | EffectPassContainer |
Container for effect passes. | |
Static Protected Attributes | |
static constexpr int | InitialEffectPassIndex |
Effect pass index for the initial pass. | |
Node effect renderer class.
Container for effect passes.
|
virtual |
Declare NodeEffectRenderer2D as not movable nor copyable.
Destructor.
|
explicitprotected |
Constructor.
nodeEffect | NodeEffect2D instance associated with this renderer. |
NodeEffect2DSharedPtr kanzi::NodeEffectRenderer2D::getEffect | ( | ) | const |
Get NodeEffect2D instance where this renderer has been instantiated from.
void kanzi::NodeEffectRenderer2D::beginEffect | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager, | ||
const Matrix3x3 & | worldTransform, | ||
const CompositionContentRequirements & | requirements ) |
Begins the effect.
Call this function before rendering the source content for the effect.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
worldTransform | 2D affine world transform used by the node. |
requirements | Requirements for the effect contents. |
void kanzi::NodeEffectRenderer2D::endEffect | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager ) |
Ends the effect.
Call this function after rendering the source content for the effect.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
void kanzi::NodeEffectRenderer2D::applyEffect | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager, | ||
const Matrix3x3 & | worldTransform, | ||
const CompositionContentRequirements & | requirements, | ||
TextureSharedPtr | sourceContent ) |
Applies the effect on the source content provided as texture.
This is an alternative to beginEffect() and endEffect(). Call either applyEffect() or beginEffect() followed by endEffect(). Do not mix them during the application of an effect.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
worldTransform | 2D affine world transform used by the node. |
requirements | Requirements for the effect contents. |
sourceContent | Source content as a texture. You can use this in place of the initial effect pass. The texture must include a one-pixel wide transparent black padding around the content. |
void kanzi::NodeEffectRenderer2D::blitEffect | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager, | ||
const QuadDescription & | effectQuad, | ||
const Matrix3x3 & | transform, | ||
const Matrix4x4 * | perspectiveMatrix, | ||
const Matrix4x4 * | projectionMatrix, | ||
int | blendMode, | ||
bool | needsClear ) |
Blits the effect to the current framebuffer.
Call this function after NodeEffectRenderer2D::endEffect when you want to blit the effect to screen. You can use this function to implement perspective projection, if you provide the relevant matrices.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
effectQuad | Potentially clipped effect quad honoring the NodeEffect2D::getEffectQuadPadding to use for rendering the effect. |
transform | 2D affine transform to use for rendering the effect quad. |
perspectiveMatrix | Optional perspective matrix to use. |
projectionMatrix | Optional projection matrix to use when rendering with perspective transform. |
blendMode | The blend mode to use for the effect blit. |
needsClear | Whether the current render target needs to be cleared before rendering. |
blendMode
parameter changed from GraphicsBlendMode to int. void kanzi::NodeEffectRenderer2D::restoreResources | ( | ) |
Restores resources after the rendering context has been lost.
size_t kanzi::NodeEffectRenderer2D::getEffectPassCount | ( | ) | const |
Gets the number of effect passes.
Sets the render effect only mode.
When enabled, compatible effects render only the effect without the source content.
renderEffectOnly | Whether to render only the effect. Default is false. |
bool kanzi::NodeEffectRenderer2D::isRenderEffectOnlyEnabled | ( | ) | const |
Whether the effect only mode is enabled.
bool kanzi::NodeEffectRenderer2D::isLayeredOnTop | ( | ) | const |
Whether a compatible effect renders logically on top of its source content.
Whether the effect is compatible with a given blend mode.
See blitEffect(). If an effect is not compatible with a blend mode, you must composite that effect and use the blend mode when blitting the composite. All effects are compatible with the GraphicsBlendModePremultipliedAlpha blend mode.
blendMode | The blend mode to test. |
Reimplemented in kanzi::OutlineEffectRenderer2D, and kanzi::ShadowEffectRenderer2D.
|
protectedpure virtual |
Begin effect.
Should be called before the source content for the effect is rendered.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
worldTransform | 2D affine world transform used by the node. |
requirements | Requirements for the effect contents. |
Implemented in kanzi::OutlineEffectRenderer2D.
|
protectedpure virtual |
End effect.
Should be called after the source content for the effect has been rendered.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
Implemented in kanzi::OutlineEffectRenderer2D.
|
protectedpure virtual |
Blit effect to current framebuffer.
Should after NodeEffectRenderer2D::endEffect when the effect should be blitted to screen. Can be used to implement perspective projection if relevant matrices are provided.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
effectQuad | Potentially clipped effect quad honoring the NodeEffect2D::getEffectQuadPadding to use for rendering the effect. |
transform | 2D affine transform to use for rendering the effect quad. |
perspectiveMatrix | Optional perspective matrix to use. |
projectionMatrix | Optional projection matrix to use when rendering with perspective transform. |
blendMode | The blend mode to use for the effect blit. |
needsClear | Whether the current render target needs to be cleared before rendering. |
blendMode
parameter changed from GraphicsBlendMode to int. Implemented in kanzi::OutlineEffectRenderer2D.
Restore resource after rendering context has been lost.
Implemented in kanzi::OutlineEffectRenderer2D.
Kanzi calls this when the render effect only mode changes.
Reimplemented in kanzi::OutlineEffectRenderer2D.
|
protected |
Clears the render target texture with a given color.
renderer | Renderer3D to use. |
compositionStack | CompositionStack to use. |
texture | Render target texture to clear. |
clearColor | Color to use for the clear. |
|
protected |
Clears the native framebuffer with a given color.
renderer | Renderer3D to use. |
compositionStack | CompositionStack to use. |
framebufferHandle | Framebuffer handle to use. |
clearColor | Color to use for the clear. |
|
protected |
Adds an effect pass and gets a reference to that pass.
Adding an effect pass invalidates references to previously added effect passes. You must add at least two effect passes. The first pass renders the contents into a render target texture, and the last pass blits the effect result.
|
protected |
Gets the index of the last effect pass.
|
protected |
Gets a reference to the effect pass at a given index.
index | Index of the effect pass. |
|
protected |
Removes all user-added effect passes, but leaves the internal initial effect pass.
|
protected |
Finalizes the effect passes.
Call this function after you have added and configured all effect passes. This function sets EffectPass::Input::releaseRenderTarget and in debug build checks whether all render pass outputs are in use.
|
protected |
Begins the initial effect pass (effect pass at index 0).
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
requirements | Requirements for the effect contents. |
|
protected |
Ends the initial effect pass, whose index is 0.
compositionStack | CompositionStack to use. |
|
protected |
Blits the intermediate effect pass.
If intermediate effect passes exist, blit them in order starting from index 1 to getEffectPassCount() - 2.
effectPassIndex | Index of the effect pass to use. |
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
|
protected |
Blits the final effect pass, whose index is getEffectPassCount() - 1, and handles the perspective transform if necessary.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
effectQuad | Potentially clipped effect quad honoring the NodeEffect2D::getEffectQuadPadding to use for rendering the effect. |
transform | 2D affine transform to use for rendering the effect quad. |
perspectiveMatrix | Optional perspective matrix to use. |
projectionMatrix | Optional projection matrix to use when rendering with perspective transform. |
blendMode | The blend mode to use for the effect blit. |
needsClear | Whether the current render target needs to be cleared before rendering. |
blendMode
parameter changed from GraphicsBlendMode to int.
|
protected |
Blits the effect pass and handles the perspective transform if necessary.
effectPassIndex | Index of the effect pass to use. |
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
effectQuad | Potentially clipped effect quad honoring the NodeEffect2D::getEffectQuadPadding to use for rendering the effect. |
transform | 2D affine transform to use for rendering the effect quad. |
perspectiveMatrix | Optional perspective matrix to use. |
projectionMatrix | Optional projection matrix to use when rendering with perspective transform. |
blendMode | The blend mode to use for the effect blit. |
needsClear | Whether the current render target needs to be cleared before rendering. |
|
protected |
Gets the texel size of the input effect pass texture in texture coordinates.
You can call this function only after the source effect pass has obtained a valid render target.
effectPassIndex | Effect pass index. |
inputIndex | Input index. |
|
protected |
Releases those temporary render targets used by input that have EffectPass::Input::releaseRenderTarget set to true.
currentEffectPass | Reference to the effect pass whose referenced render targets to release if necessary. |
compositionManager | CompositionManager used to get the temporary render targets. |
|
protected |
Whether the initial pass render target is temporary.
See applyEffect().
Configures the initial effect pass.
sourceContentSize | Size of the source content. |
Sets whether the effect is layered on top of the source content.
layeredOnTop | If layered on top of the source content, true, otherwise false. |
Effect pass index for the initial pass.